﻿
/// <reference path="_namespace.js" />
/// <reference path="../BaseObject.js" />

/*****************************************************************************
Ajax library class definition. Kevin Robinson 2006.
Class: NOT USED AFAIK!!
/*****************************************************************************/

ajax.lang.addNamespace("ajax.geometry");

//-----------------------------------------------------------------------------
ajax.geometry.Vertex = function(x, y, xVel, yVel)
{
    ajax.geometry.Vertex.superConstructor.call(this);
    
    this.position = {x: x, y: y};
    this.velocity = {x: xVel, y: yVel};       
}

//-----------------------------------------------------------------------------
ajax.lang.extend("ajax.geometry.Vertex", "ajax.BaseObject"); // Inherit
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
ajax.geometry.Vertex.prototype.update = function()
{
    this.position.x += this.velocity.x;
    this.position.y += this.velocity.y;
}

//-----------------------------------------------------------------------------
ajax.geometry.Vertex.prototype.checkBounds = function(rect, bBounce)
{
    if (this.position.x <= 0 || this.position.x >= rect.width)
    {
        this.position.x = Math.max(0, this.position.x);
        this.position.x = Math.min(rect.width, this.position.x);
        if (bBounce)
            this.velocity.x *= -1;
    }
    if (this.position.y <= 0 || this.position.y >= rect.height)
    {
        this.position.y = Math.max(0, this.position.y);
        this.position.y = Math.min(rect.height, this.position.y);
        if (bBounce)
            this.velocity.y *= -1;
    }
}


//-----------------------------------------------------------------------------
ajax.geometry.Vertex.prototype.toString = function()
{
    return "ajax.geometry.Vertex";
}

//-----------------------------------------------------------------------------
ajax.geometry.Vertex.cast = function(obj)
{///<returns type="ajax.geometry.Vertex"/>
    return obj;    
}